package com.wfw.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.wfw.common.Const;
import lombok.Data;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResultVo<T> {
    private Integer code;

    private String msg;

    private T data;

    private ResultVo(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    private ResultVo(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ResultVo createBySuccess(){
        return new ResultVo(0, Const.SUCCESS);
    }
    public static ResultVo createBySuccessMsg(String msg){
        return new ResultVo(0, msg);
    }
    public static <T> ResultVo createBySuccessData(T data){
        return new ResultVo(0, Const.SUCCESS,data);
    }
    public static <T> ResultVo createBySuccessMsgData(String msg,T data){
        return new ResultVo(0, msg,data);
    }
    public static ResultVo createByError(){
        return new ResultVo(1, Const.FAIL);
    }
    public static ResultVo createByErrorMsg(String msg){
        return new ResultVo(1, msg);
    }
}
